package com.ruoyi.points.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.points.domain.VideoPoints;
import com.ruoyi.points.service.IVideoPointsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * pointsController
 * 
 * @author ruoyi
 * @date 2025-05-10
 */
@RestController
@RequestMapping("/points/VideoPoints")
public class VideoPointsController extends BaseController
{
    @Autowired
    private IVideoPointsService videoPointsService;

    /**
     * 查询points列表
     */
    @PreAuthorize("@ss.hasPermi('points:VideoPoints:list')")
    @GetMapping("/list")
    public TableDataInfo list(VideoPoints videoPoints)
    {
        startPage();
        List<VideoPoints> list = videoPointsService.selectVideoPointsList(videoPoints);
        return getDataTable(list);
    }

    /**
     * 导出points列表
     */
    @PreAuthorize("@ss.hasPermi('points:VideoPoints:export')")
    @Log(title = "points", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VideoPoints videoPoints)
    {
        List<VideoPoints> list = videoPointsService.selectVideoPointsList(videoPoints);
        ExcelUtil<VideoPoints> util = new ExcelUtil<VideoPoints>(VideoPoints.class);
        util.exportExcel(response, list, "points数据");
    }

    /**
     * 获取points详细信息
     */
    @PreAuthorize("@ss.hasPermi('points:VideoPoints:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(videoPointsService.selectVideoPointsByUserId(userId));
    }

    /**
     * 新增points
     */
    @PreAuthorize("@ss.hasPermi('points:VideoPoints:add')")
    @Log(title = "points", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VideoPoints videoPoints)
    {
        return toAjax(videoPointsService.addPoint(videoPoints));
    }

    /**
     * 修改points
     */
    @PreAuthorize("@ss.hasPermi('points:VideoPoints:edit')")
    @Log(title = "points", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VideoPoints videoPoints)
    {
        return toAjax(videoPointsService.updateVideoPoints(videoPoints));
    }

    /**
     * 删除points
     */
    @PreAuthorize("@ss.hasPermi('points:VideoPoints:remove')")
    @Log(title = "points", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(videoPointsService.deleteVideoPointsByUserIds(userIds));
    }
}
